﻿
/****************************** Module Header ******************************\

Copyright (c) Gary Davidson

This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.

THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/

using System.Collections.Generic;
using System.Xml.Linq;

namespace Savviety.ServiceManager.Facade.Criteria
{
    public class AndExpression : CriteriaElement
    {
        private readonly List<SimpleExpression> simpleExpressions;

        public AndExpression(XNamespace ns, List<SimpleExpression> simpleExpressions) : base(ns)
        {
            this.simpleExpressions = simpleExpressions;
        }

        internal override XElement ToXElement()
        {
            var addElement = new XElement(Namespace + "Expression",
                                          new XElement(Namespace + "And"));

            foreach (var simpleExpression in simpleExpressions)
            {
                addElement.Add(simpleExpression.ToXElement());
            }
            return addElement;
        }
    }
}